package com.share.dgs.fetcher;

import com.netflix.graphql.dgs.DgsComponent;
import com.netflix.graphql.dgs.DgsData;
import graphql.schema.DataFetchingEnvironment;
import org.dataloader.DataLoader;

import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * @author caifan
 * @created 2021/3/5
 * description:
 */
@DgsComponent
public class CurrentTimeDateFetcher {
    @DgsData(parentType = "Query", field = "now")
    public LocalDateTime now() {
        return LocalDateTime.now();
    }

    @DgsData(parentType = "Query", field = "schedule")
    public boolean schedule(DataFetchingEnvironment env) {
        DataLoader<Object, Object> messages = env.getDataLoader("messages");
//        String key = messages.load("");
        LocalDateTime time = env.getArgument("time");
        System.out.println(time);
        return true;
    }
}
